<%@ page language="java" import="java.util.*" import="java.text.SimpleDateFormat" pageEncoding="UTF-8"%>
<%@ page import="com.bluesky.light.user.*" %>
<%
	request.setCharacterEncoding("UTF-8");
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	// check if the user is login
	User u = (User)session.getAttribute("user");
	if (u == null) {
		response.sendRedirect("index.jsp");
	}
	String name = u.getName();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>light - home</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="css/main.css" rel="stylesheet" type="text/css" />
	
	<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=abcdefg&sensor=true"
            type="text/javascript">
    </script>
    <script type="text/javascript">

	    //<![CDATA[
	    var map = null;
	    var geocoder = null;

		function initialize() {
	      //檢查瀏覽器是否可用GOOGLE MAP API
	      if (GBrowserIsCompatible()) {
	          map = new GMap2(document.getElementById("map_canvas"));
	          //GClientGeocoder類實現找圖功能
	          geocoder = new GClientGeocoder(); 
	          
	     	  //設定中心點
	          map.setCenter(new GLatLng(30.5074, 114.4137), 14);
	     	  //允許地圖雙擊放大
			  map.enableDoubleClickZoom();
	     	  //允許滾輪縮放
			  map.enableScrollWheelZoom();
	     	  //打開GOOGLE地圖的搜尋欄
	     	  map.enableGoogleBar();
	      }
		}

	   // showLocation() is called when you click on the Search button
	   // in the form.  It geocodes the address entered into the form
	   // and adds a marker to the map at that location.
	   function showLocation() {
	       var address = document.forms[0].loc.value;
	       geocoder.getLocations(address, addAddressToMap);
	   }
	       
	   // addAddressToMap() is called when the geocoder returns an
	   // answer.  It adds a marker to the map with an open info window
	   // showing the nicely formatted version of the address and the country code.
	   function addAddressToMap(response) {
	       map.clearOverlays();
	       if (!response || response.Status.code != 200) {
	           alert("查無資料！\n Sorry, we were unable to geocode that address");
	       } // if
	       else {
	           place = response.Placemark[0];
	           //定义一个经纬度点GLatLng()
	           point = new GLatLng(place.Point.coordinates[1],
	                               place.Point.coordinates[0]);
	           //定义一个标注对象GMarker()
	           marker = new GMarker(point);
	           //在地图上加入标注GMap2.addOverlay()
	           map.addOverlay(marker);
	           marker.openInfoWindowHtml(place.address);
	       } // else
	   }
	       
	       //]]>
	     		
    </script>
  </head>
 
  <body onload="initialize()" onunload="GUnload()">
	<!-- header -->
	<div id="header">
		<div id="logo"><img src="images/logo_small2.png"/></div>
	</div>
	<!-- // header -->
	<!-- nav -->
	<div id="nav">
	</div>
	<!-- // nav -->
	<!-- container -->
	<div id="container">
		<!-- contents -->
		<div id="contents">
	    	<div id="menu">
	        	<div>
	        		<div id="user_info">
	            		<img src="develop/user_icon.jpg"/> 
	            		<b>User</b>
	           		</div>
	           		<div>
	           		<%=name%>
	           		</div>
	            </div>
	            <div>
	            	<%SimpleDateFormat sdf = new SimpleDateFormat("EEE, yyyy-MM-dd", new Locale("US"));%><%=sdf.format(new Date())%><br></br>
	            </div>
	        	<ul>
					<li><a href="home.jsp"><img src="images/news.png" /> Health News</a></li>
	                <li><a href="user_subscribe.jsp"><img src="images/surscribe.png" /> Appointment</a></li>
	                <li><a href="user_history.jsp"><img src="images/account.png" /> Health History</a></li>
	                <li><a href="user_hospitalSearchOnMap.jsp"><img src="images/photo.png" /> Searching Hospital</a></li>
	                <li><a href="user_bodyCheckResult.jsp"><img src="images/surscribe.png" /> Body Check Result</a></li>	          
	                <li><a href="user_infoModifyInput.jsp"><img src="images/account.png" /> Account Management</a></li>
	                <li><a href="index.jsp"><img src="images/account.png" /> Logout</a></li>
	            </ul>
	        </div>
	        <div id="main-cont">
				<!-- Search list -->
	        	<form method="get" onsubmit="showLocation(); return false;">
	            <div id="search_on_map">
	                <table class="search_on_map_table" rules="all" >
	                	<caption>Hospital Search</caption>
	                </table>		
	        	</div>	        	
	        	</form>
				<div id="map_canvas" style="width: 700px; height: 430px"></div>
	        </div>
	    </div>
	    <!-- // contents -->
	</div>
	<!-- // container -->
	<div id="footer">
		<div id="bs_stdio">
	    	©2011-2011 www.bluesky.com.mo All Rights Reserved<br/>
	    	<img src="images/bluesky_logo.png" />
	    </div>
	</div>
  </body>
</html>
